/**
 * 
 */
package com.sicocre.business.dao.impl;

import javax.sql.DataSource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.sicocre.beans.Banco;
import com.sicocre.business.dao.IBancoDao;

/**
 * @author lserrano
 *
 */

@Repository
public class BancoDaoImpl implements IBancoDao {
	
		
	private JdbcTemplate jdbcTemplate;
	
	public static final String INSERT_BANCO = "INSERT INTO sicocre.bancos(nombre_banco,activo) VALUES(?,?)";
	    
    @Autowired
	public void setDataSource(DataSource ds){
		jdbcTemplate=new JdbcTemplate(ds);
	}
	
    
    
	public int insertar(Banco banco) {
		// TODO Auto-generated method stub
		
		int activo;
		
		if (banco.isActivo()){
			activo = 1;
		}else{
			activo = 0;	
		}
			
		int insertBanco = jdbcTemplate.update(INSERT_BANCO,new Object[]{banco.getNombreBanco(),activo});
				
		return insertBanco;
	}
	
	

}
